<template>
  <view class="container" v-if="info.express_no">
    <!-- 物流公司 -->
    <view class="header">

      <view class="title" v-if="info.express_name">
        <text>物流公司：</text> <text class="col-m">{{ info.express_name }}</text>
      </view>
      <view class="title">
        <text>物流单号：</text> <text class="col-m">{{ info.express_no }}</text>
       <u-icon class="icon-copy" name="/static/images/copy.png" @click="copyText(info.express_no)" size="36"></u-icon>
      </view>


    </view>
    <!-- 物流动态 -->
    <view class="logs-list">

      <u-time-line v-if="info.logs.length > 0 > 0">
      <u-time-line-item nodeTop="2" v-for="(item, index) in info.logs" :key="index">
        <template  v-slot:node>
          <view :class="'u-node '+(index==0?'item-active':'item-unactive')" >
            <u-icon :name="index===0?'clock':'map'" color="#fff" :size="24"></u-icon>
          </view>
        </template>
        <template v-slot:content>
          <view>
            <view class="u-order-title">{{item.time}}</view>
            <view class="u-order-desc">
              <rich-text :nodes="item.content"></rich-text>
            </view>
            <view class="u-order-time"></view>
          </view>
        </template>
      </u-time-line-item>
    </u-time-line>
    </view>

  </view>
</template>

<script>
import order_api from "@/common/order_api";

export default {
  data() {
    return {
      options: {},
      info: {
        express_name: '',
        express_no: '',
        logs: []
      }
    };
  },
  onLoad: function (options) {
    this.options = options;
    this.getData(options.order_sn);
  },
  onPullDownRefresh() {
    this.logs = []
    this.getData(this.options.order_sn)
    setTimeout(()=>{
      uni.stopPullDownRefresh()
    },1000)
  },
  methods: {
    getData: function (order_sn) {
      uni.showLoading({
        title: '信息查询中...'
      })
      let that = this;
      order_api.express({
        order_sn: order_sn
      }).then(res => {
        if (res.code !== 0) {
          that.$u.toast(res.msg);
          setTimeout(function () {
            uni.navigateBack();
          }, 2000)
          return;
        }
        that.setData(res.data);
      }).finally(() => {
        uni.hideLoading();
      })

    }
  }
};
</script>
<style lang="scss">
@import 'index.scss';
</style>
